<?php
require $_SERVER["DOCUMENT_ROOT"] . "/aonce_connect.php";

/*
 * Primer capa de validacion de obtencion de datos de artista
 * Metodos POST & GET cubuertos
 */

$expo = isset($_GET["expo"]) ? $_GET["expo"] : NULL;
if($expo == NULL)
	$expo = isset($_POST["expo"]) ? $_POST["expo"] : NULL;
$esNuevaExpo=false;
if($expo == NULL){
	$err_msg = "Exposicion no econtrada";
	$esNuevaExpo = true;
//	redirect_error($msg);
//	printf($err_msg);
}

if($expo!=NULL){
/*
 * Queries de obtenci'on de informaci'on de la exposicion y sus fotos
 */
$expo_fields = "nombreexpo AS titulo, inicioexpo AS inicio, finexpo AS fin, textoexpo AS texto, fotoexpo AS foto, artistasexpo AS artistas";
$expo_query = "SELECT $expo_fields FROM expo WHERE idexpo=$expo LIMIT 1;";

$picsexpo_fields = "idpicsexpo, titulopicsexpo AS titulo, yearpicsexpo AS year, materialexpo AS material, medidasexpo AS medidas, fotoexpo AS foto, orientacionexpo AS ori";
$picsexpo_query = "SELECT $picsexpo_fields FROM picsexpo WHERE expo=$expo LIMIT 18;";
//echo $picsexpo_query;

/*
 * Conexion a DB y ejecuci'on de queries
 */
$link = conecta();
$expo_result = $link->query($expo_query);
$picsexpo_result = $link->query($picsexpo_query);
//var_dump($link);
$link->close();
/*
 * Asociaci'on de datos de artista y serie con variables
 */
$expo_data = $expo_result->fetch_assoc();
}

?>
<!--Force IE6 into quirks mode with this comment tag-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Alternativa Once</title>
<link href="styleIndex.css" rel="stylesheet" type="text/css" />
<link href="styleArtista.css" rel="stylesheet" type="text/css" />
<link href="styleFormas.css" rel="stylesheet" type="text/css" />
<!-- calendar stylesheet -->
  <link rel="stylesheet" type="text/css" media="all" href="calendar-win2k-cold-1.css" title="win2k-cold-1" />
  <!-- main calendar program -->
  <script type="text/javascript" src="js/calendar.js"></script>
  <!-- language for the calendar -->
  <script type="text/javascript" src="js/calendar-en.js"></script>
  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="js/calendar-setup.js"></script>
<script>
  function changeimage(towhat,url){
    if (document.images){
      document.images.targetimage.src=towhat.src
      gotolink=url
    }
  }
  
  function warp(){
    window.location=gotolink
  }
  
  </script>
  
  <script language="JavaScript1.1">
  var myimages=new Array()
  var gotolink="#"
  
  function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
    myimages[i]=new Image()
    myimages[i].src=preloadimages.arguments[i]
    }
  }
  
  preloadimages("images/img01.gif","images/pic02.gif","images/pic03.gif","images/pic04.gif","images/pic05.gif")
</script>
</head>
<body>

<div id="framecontent">
<div class="seccioninterior">

<div id="navcontainer">
<ul>
   <li><a href="#">Terms & Conditions</a></li>
   <li><a href="#">Copyright Information</a></li>
   <li><a href="#">Privacy Policy</a></li>
   <li style="border:0"><a href="#">Sitemap</a></li>                                                    
</ul> 
</div>  

</div>
</div>

<div id="maincontent">

<?php require "head.php";?>

<h1 class="tituloNuevaConvocatoria">
<?php
if($esNuevaExpo){
		echo "Nueva Exposici&oacute;n";
}
else
		echo "Exposici&oacute;n $expo";
?>
</h1>
<div class="seccioninterior" style="margin-top:40px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px">
		<form enctype="multipart/form-data" action="alta_expo.php<?php if(!$esNuevaExpo) echo "?expo=$expo";?>" method="POST">
		<div style="margin-bottom:10px"><div class="tagTituloIzquierdo">T&iacute;tulo:</div><input name="tituloexpo" type="text" class="textDerecho" value="<?php printf("%s",$expo_data['titulo']);?>"/></div>
<div style="margin-bottom:10px">
	<div class="tagTituloIzquierdo">Datos Generales:</div>
	<textarea name="dgen" rows="10" class="textDatosGenerales"><?php printf("%s",$expo_data['texto']);?></textarea>
</div>
<div style="margin-bottom:10px">
	<div class="tagTituloIzquierdo">Texto Completo:</div>
	<textarea name="artistas" rows="10" class="textDatosCompletos"><?php printf("%s",$expo_data['artistas']);?></textarea>
</div>
<?php
if($picsexpo_result){
		$c=1;
	while($picsexpo_data = $picsexpo_result->fetch_assoc()){
		printf("\t<div class=\"divInfoExpoActual\">\n");
		printf("\t\t<div class=\"infoId\"> No.%d</div>\n", $c++);
		printf("\t\t<div class=\"infoDescripcion\">%s</div>\n", $picsexpo_data['titulo']);
		printf("\t\t<div class=\"borrarDatosExpo\"><a href=\"borra_pic.php?pic=%d\">[ borradme ]</a></div>\n", $picsexpo_data['idpicsexpo']);
		printf("\t</div>\n");
	}
}
?>
<div class="divNuevaExpoBottom">
	<div class="tagTituloIzquierdo">Fecha Inicio:</div>	
	<div>
	<input type="text" name="finicio" id="f_date_c1" readonly="1" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; float:left; border:1px solid #888; " value="<?php if(!$esNuevaExpo && $expo_data["inicio"]) printf("%s", date_format(date_create($expo_data["inicio"]), 'Y-m-d'));?>"/>
		<img src="images/calendario.gif" id="f_trigger_c1" style="cursor: pointer; border: 0px solid red; float:left" title="Date selector" onmouseover="this.style.background='red';" onMouseOut="this.style.background=''" />
	</div>
	<div class="tagTituloIzquierdo">Fecha Cierre:</div>	
	<div>
		<input type="text" name="ffin" id="f_date_c2" readonly="1" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; float:left; border:1px solid #888; " value="<?php if(!$esNuevaExpo && $expo_data["fin"]) printf("%s", date_format(date_create($expo_data["fin"]), 'Y-m-d'));?>"/>
		<img src="images/calendario.gif" id="f_trigger_c2" style="cursor: pointer; border: 0px solid red; float:left" title="Date selector" onmouseover="this.style.background='red';" onMouseOut="this.style.background=''" />
	</div>

	<script type="text/javascript">
		Calendar.setup({
			inputField     :    "f_date_c1",     // id of the input field
			ifFormat       :    "%Y-%m-%d",      // format of the input field
			button         :    "f_trigger_c1",  // trigger for the calendar (button ID)
			align          :    "Tl",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
		Calendar.setup({
			inputField     :    "f_date_c2",     // id of the input field
			ifFormat       :    "%Y-%m-%d",      // format of the input field
			button         :    "f_trigger_c2",  // trigger for the calendar (button ID)
			align          :    "Tl",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
	</script>


	<div class="tagTituloIzquierdo">Imagen (360 x 183):</div>
	<input type="file" name="uploadedfile[]" class="inputFileExpo">	
	<input type="hidden" name="MAX_FILE_SIZE" value="100000" />

	<div class="tagTituloIzquierdo">Thumbnail (74 x 74):</div>
	<input type="file" name="uploadedfile[]" class="inputFileExpo">
	<input type="hidden" name="thumb_MAX_FILE_SIZE" value="10000" />
</div>

<div class="divTituloDerecho">
	<div class="divTagDerecho">
		<div class="tagTituloDerecho">T&iacute;tulo:</div>
		<input name="titulo" type="text" class="textDerechoExpo"/>
	</div>
	<div class="divTituloDerecho">
		<div class="tagTituloDerecho">A&ntilde;o:</div>
		<input name="year" type="text" class="textDerechoExpo"/>
	</div>
	<div class="divTituloDerecho">
		<div class="tagTituloDerecho">Material:</div>
		<input name="material" type="text" class="textDerechoExpo"/>
	</div>
	<div class="divTituloDerecho">
		<div class="tagTituloDerecho">Medidas:</div>
		<input name="medidas" type="text" class="textDerechoExpo"/>
	</div>
	<input type="submit" value="Guardar Cambios" />
	</form>
</div>

</div>
</div>


</body>
</html>
